{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "cd3beae8",
   "metadata": {},
   "source": [
    "# week09课后练习笔记"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "a691e25b",
   "metadata": {},
   "source": [
    "## P67课后练习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "593e48b2",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase=\"Don't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "583c6a68",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "78168364",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "85f509b3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "c2d79159",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_phrase = ''.join(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "2df3316d",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "8e10ef14",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n"
     ]
    }
   ],
   "source": [
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c276041c",
   "metadata": {},
   "source": [
    "## 把\"Don't panic\"转换为\"on tap\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "3c9a3d86",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase=\"Don't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "24064b44",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "1e4781d3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "a7f674fa",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "5803f6c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "for i in range(4):\n",
    "    plist.pop()\n",
    "plist.pop(0)\n",
    "plist.remove(\"'\")\n",
    "plist.extend([plist.pop(),plist.pop()])\n",
    "plist.insert(2,plist.pop(3))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "c50bf8dd",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['o', 'n', ' ', 't', 'a', 'p']\n",
      "on tap\n"
     ]
    }
   ],
   "source": [
    "new_phrase=''.join(plist)\n",
    "print(plist)\n",
    "print(new_phrase)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f33d8ff9",
   "metadata": {},
   "source": [
    "## P81课后练习笔记"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7bd076e3",
   "metadata": {},
   "outputs": [],
   "source": [
    "phrase=\"Don't panic!\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "6185565b",
   "metadata": {},
   "outputs": [],
   "source": [
    "plist = list(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "56b41924",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Don't panic!\n"
     ]
    }
   ],
   "source": [
    "print(phrase)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "ee89bddb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "a3159ef5",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_phrase=\"on\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "a767b470",
   "metadata": {},
   "outputs": [],
   "source": [
    "new_phrase=new_phrase+\"tap\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "a0ac6739",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['D', 'o', 'n', \"'\", 't', ' ', 'p', 'a', 'n', 'i', 'c', '!']\n"
     ]
    }
   ],
   "source": [
    "print(plist)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "6bdf99e3",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "ontap\n"
     ]
    }
   ],
   "source": [
    "print(new_phrase)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
